<?php
/**
 *
 */
class UploadHelper{
    /**
     * allow user save
     * @param CUploadedFile $uploadFile
     * @return mixed boolean if upload fail
     *
     */
    public static function saveAvatar($uploadFile){
        //allow extensions?
        if(!in_array($uploadFile->extensionName, array('png', 'jpg', 'jpeg', 'bmp', 'gif'))){
            return false;
        }

        $fileName = time().'.'.$uploadFile->extensionName;
        if($uploadFile->saveAs(AVATAR_PATH . $fileName)){
            //save file successfully
            return $fileName;
        }

        return false;
    }
}